
/*
######################################################################################################
#                                                                                                    # 
#	this page is used by dentist to change his password                                                                                                 #
#	Author: Ranjeet
#	Date: 26/02/08                                                                                   # 
#	                                                                                                 # 
######################################################################################################
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;


public partial class Dentist_DentistChangePassword : System.Web.UI.Page
{
    // creating an instance of manager class
    Manager objManager;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Check Doctor login
        localFunction lFunction = new localFunction();
        lFunction.checkDentistLogin(true);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //Change the old password of a login doctor
        string strSql = "select password from tbl_dentists where id='" + Session["userID"] + "' and password='" + txtOPass.Text.Replace("'", "''") + "' and isdelete=0";
        objManager = new Manager(true,"ConnectionString");
        object objpass = null;
        objpass = objManager.ExecuteScalarQuery(strSql);
        if (objpass != null)
        {
            objManager.ExecuteUpdate("update tbl_dentists set password='" + txtPass.Text.Replace("'", "''") + "' where id='" + Session["userID"] + "' and password='" + txtOPass.Text.Replace("'", "''") + "' and isdelete=0");
            lblAccessMessage.Text = "You have successfully changed your password";
        }
        else
        {            
            lblAccessMessage.Text = "Old password is wrong";
        }
        objManager = null;
        //System.Data.SqlClient.SqlDataReader sqlDr;
        //sqlDr = objManager.ExecuteQuery(strSql);
        //if (sqlDr.Read())
        //{
        //    sqlDr.Close();
        //    objManager.ExecuteUpdate("update tbl_dentists set password='" + txtPass.Text.Replace("'", "''") + "' where id='" + Session["userID"] + "' and password='" + txtOPass.Text.Replace("'", "''") + "' and isdelete=0");
        //    lblAccessMessage.Text = "You have successfully changed your password";
        //}
        //else
        //{
        //    sqlDr.Close();
        //    lblAccessMessage.Text = "Old password is wrong";
        //}
        
    }
}
